<?php
include ("../include/config.php");
require($config['basedir']."/include/authenticate.php");
require($config['basedir']."/admin/classes/users.class.php");
$post = $_REQUEST;
$objUser = new Users();
$_action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';

switch($_action) { 
	
	case 'edit':
		
		if (isset($post['submit']))
		{
			$objUser->updateUser($post);
		}
		$users = $objUser->getUserById($post['user_id']);
		stemplate::assign("post", $users);
		stemplate::display("admin/users/save.tpl");
	break;
	
	case 'delete':
			$objUser->deleteUser($post);
			global $pager;
			$data = $_REQUEST;
			$banner_list = $objUser->getUsers($post);
			stemplate::assign('banner_list', $banner_list);
			stemplate::display("admin/users/list.tpl");
		
	break;	
	case 'view':
	default:
		$post = $_REQUEST;
		if($_REQUEST['added'] == 1)	{
			global $msgOk;
			$msgOk = 'User  added successfully.';
		}elseif($_REQUEST['updated'] == 1){
			global $msgOk;
			$msgOk = 'User  updated successfully.';
		}elseif($_REQUEST['deleted'] == 1){
			global $msgOk;
			$msgOk = 'User  deleted successfully.';
		}
		
		$users = $objUser->getUser($post);
		stemplate::assign('post', $post);
		stemplate::assign('users', $users);
		stemplate::assign("total_records", $pager->items_total);
  		stemplate::assign("pagination_start", $pager->low);
		stemplate::assign("page_limit_select", $pager->display_page_limits());
  		stemplate::assign("pagination",$pager->display_pages());
		stemplate::display("admin/users/list.tpl");
		
    break; 

}
?>